<?php $seller_id = $this->seller['seller_id'];$seller_name = $this->seller['seller_name'];?>
<?php $query = new IQuery("seller");$query->where = "id = $seller_id";$items = $query->find(); foreach($items as $key => $item){?>
<?php $member_id = $item['member_id']?>
<?php }?>

<?php $query = new IQuery("user");$query->where = "id = $member_id";$items = $query->find(); foreach($items as $key => $item){?>
<?php $user_ava = $item['head_ico']?>
<?php $user_id = $item['id']?>
<?php $user_name = $item['username']?>
<?php }?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="<?php echo $this->getWebSkinPath()."css/chat.css";?>">
	
	<title>商家管理后台</title>
	<link type="image/x-icon" href="<?php echo IUrl::creatUrl("")."favicon.ico";?>" rel="icon">
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/jquery/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artdialog/artDialog.js"></script><script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artdialog/plugins/iframeTools.js"></script><link rel="stylesheet" type="text/css" href="/git/micarshop/runtime/_systemjs/artdialog/skins/aero.css" />
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/form/form.js"></script>
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artTemplate/artTemplate.js"></script><script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artTemplate/artTemplate-plugin.js"></script>
	<script type='text/javascript' src="<?php echo $this->getWebViewPath()."javascript/html5.js";?>"></script>
	<script type='text/javascript' src="<?php echo $this->getWebViewPath()."javascript/common.js";?>"></script>
	<!--[if lt IE 9]>
	<link rel="stylesheet" href="<?php echo $this->getWebSkinPath()."css/ie.css";?>" type="text/css" media="screen" />
	<![endif]-->
	<link rel="stylesheet" href="<?php echo $this->getWebSkinPath()."css/admin.css";?>" type="text/css" media="screen" />
	<script type="text/javascript" src="<?php echo $this->getWebViewPath()."javascript/chat.js";?>"></script>
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/autovalidate/validate.js"></script><link rel="stylesheet" type="text/css" href="/git/micarshop/runtime/_systemjs/autovalidate/style.css" />
	
	<script type="text/javascript">
		var user_ava = '<?php echo isset($user_ava)?$user_ava:"";?>';
	</script>
	
	<script type="text/javascript">
			console.log("id is "+<?php echo isset($user_id)?$user_id:"";?>);
		</script>
	
</head>

<body>
	<!--头部 开始-->
	<header id="header">
		<hgroup>
			<h1 class="site_title"><a href="<?php echo IUrl::creatUrl("/seller/index");?>"><img src="<?php echo $this->getWebSkinPath()."images/main/logo.png";?>" /></a></h1>
			<h2 class="section_title"></h2>
			<div class="btn_view_site"><a href="<?php echo IUrl::creatUrl("");?>" target="_blank">网站首页</a></div>
			<div class="btn_view_site"><a href="<?php echo IUrl::creatUrl("/site/home/id/".$seller_id."");?>" target="_blank">商家主页</a></div>
			<div class="btn_view_site"><a href="<?php echo IUrl::creatUrl("/systemseller/logout");?>">退出登录</a></div>
		</hgroup>
	</header>
	<!--头部 结束-->

	<!--面包屑导航 开始-->
	<section id="secondary_bar">
		<div class="user">
			<p><?php echo isset($seller_name)?$seller_name:"";?></p>
		</div>
	</section>
	<!--面包屑导航 结束-->

	<!--侧边栏菜单 开始-->
	<aside id="sidebar" class="column">
		<?php foreach(menuSeller::init() as $key => $item){?>
		<h3><?php echo isset($key)?$key:"";?></h3>
		<ul class="toggle">
			<?php foreach($item as $moreKey => $moreValue){?>
			<li><a href="<?php echo IUrl::creatUrl("".$moreKey."");?>"><?php echo isset($moreValue)?$moreValue:"";?></a></li>
			<?php }?>
		</ul>
		<?php }?>

		<footer>
			<hr />
			<p><strong>Copyright &copy; 2010-2015 iWebShop</strong></p>
			<p>Powered by <a href="http://www.aircheng.com">iWebShop</a></p>
		</footer>
	</aside>
	<!--侧边栏菜单 结束-->

	<!--主体内容 开始-->
	<section id="main" class="column">
		<?php $data=$this->data_info?>
<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artTemplate/artTemplate.js"></script><script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artTemplate/artTemplate-plugin.js"></script>

<article class="module width_full">
	<header>
		<h3 class="tabs_involved">运费编辑</h3>
	</header>

	<form action='<?php echo IUrl::creatUrl("/seller/delivery_update");?>' method='post' name='form'>
		<input type="hidden" name="deliveryId" value="<?php echo IFilter::act(IReq::get('id'),'int');?>" />

		<div class="module_content">
			<fieldset>
				<label>重量设置</label>
				<div class="box">
					首重重量
					<select name="first_weight" pattern='int' class='auto'>
						<option label="500克" value="500">500克</option>
						<option label="1公斤" value="1000" selected="selected">1公斤</option>
						<option label="1.2公斤" value="1200">1.2公斤</option>
						<option label="2公斤" value="2000">2公斤</option>
						<option label="5公斤" value="5000">5公斤</option>
						<option label="10公斤" value="10000">10公斤</option>
						<option label="20公斤" value="20000">20公斤</option>
						<option label="50公斤" value="50000">50公斤</option>
					</select>

					首重费用
					<input class='tiny' name="first_price" value=""  pattern="float" alt="该项必填且只允许填写数字金额" type="text">元，

					续重重量
					<select name="second_weight" pattern='int' class='auto'>
						<option label="500克" value="500">500克</option>
						<option label="1公斤" value="1000" selected="selected">1公斤</option>
						<option label="1.2公斤" value="1200">1.2公斤</option>
						<option label="2公斤" value="2000">2公斤</option>
						<option label="5公斤" value="5000">5公斤</option>
						<option label="10公斤" value="10000">10公斤</option>
						<option label="20公斤" value="20000">20公斤</option>
						<option label="50公斤" value="50000">50公斤</option>
					</select>

					续重费用
					<input class='tiny' name="second_price" value="" pattern="float" alt="该项必填且只允许填写数字金额" type="text">元
				</div>
				<label class="tip">根据重量来计算运费，当物品不足《首重重量》时，按照《首重费用》计算，超过部分按照《续重重量》和《续重费用》乘积来计算</label>
			</fieldset>

			<fieldset>
				<label>支持保价</label>
				<div class="box">
					<label><input name="is_save_price" value="1" type="checkbox" onclick="$('#protectBox').toggle();"> 支持物流保价</label>

					<!--支持保价隐藏域-->
					<span id='protectBox' style='display:none'>
						，费率<input name="save_rate" value="" class='tiny' pattern="float" alt="该项必填且只允许填写数字金额" type="text" />%
						，最低保价费<input name="low_price" value="" class='tiny' pattern="float" alt="该项必填且只允许填写数字金额" type="text" />元
						<label class="tip">当用户需要保价后，一般是按照货物总金额的《费率》计算，但是保价金额最低不低于《最低保价费》</label>
					</span>
				</div>
			</fieldset>

			<fieldset>
				<label>设置地区运费</label>
				<div class="box">
					<label><input name="price_type" value="0" type="radio" onclick="$('#areaBox').hide();" checked="checked">统一地区运费</label>
					<label><input name="price_type" value="1" type="radio" onclick="$('#areaBox').show();">指定地区运费</label>
					<label class="tip">《统一地区运费》：全部的地区都使用默认的《重量设置》中的计费方式。《指定地区运费》：单独指定部分地区的运费</label>
				</div>
			</fieldset>

			<!--按照地区设置-->
			<fieldset id="areaBox" style='display:none'>
				<label>支持的配送地区</label>
				<div class="box">
					<label><input name="open_default" value="1" type='checkbox' /> 其他地区默认运费</label>
					<label class="tip">注意：如果不开启此项，那么未设置的地区将无法送达！</label>

                    <div id="deliveryAreaBox"></div>

                    <!--地域设定模板-->
                    <script type='text/html' id='areaTemplate'>
					<div style='padding:6px;border: 1px solid #BBBBBB;margin-bottom:10px;'>
						<input type='hidden' name='area_groupid[]' value='<%=area_groupid%>' />
						选择地区：
						<select class="auto">
							<?php foreach($this->areaList as $key => $item){?>
								<option value="<?php echo isset($item['area_id'])?$item['area_id']:"";?>"><?php echo isset($item['area_name'])?$item['area_name']:"";?></option>
							<?php }?>
						</select>
						<button type="button" class="btn" onclick='addProvince(this);'><span class="add">添加</span></button>
						<label>首重费用：<input class="tiny" name="firstprice[]" value="<%=firstprice%>" pattern="float" alt="该项必填且只允许填写数字金额" type="text" /></label>
						<label>续重费用：<input class="tiny" name="secondprice[]" value="<%=secondprice%>" pattern="float" alt="该项必填且只允许填写数字金额" type="text" /></label>
						<label><a href="javascript:void(0)" onclick="$(this).parent().parent().remove();"><img alt="删除" src="<?php echo $this->getWebSkinPath()."images/main/icn_del.png";?>" class="operator"/></a></label>
						<textarea name="areaName" readonly="readonly" disabled='disabled' style='width:85%;float:none;margin-left:0px;display:block'><%=areaname%></textarea>已选择的地区
					</div>
                    </script>
				</div>
				<div class="box"><button type="button" class="btn" onclick='addArea()'><span class="add">添加地区</span></button></div>
			</fieldset>
		</div>

		<footer>
			<div class="submit_link">
				<input type="submit" class="alt_btn" value="确 定" />
				<input type="reset" value="重 置" />
			</div>
		</footer>
	</form>
</article>

<script type='text/javascript'>
//DOM加载完毕
$(function()
{
	//初始化表单
	var formInstance = new Form('form');
	formInstance.init(<?php echo JSON::encode($data);?>);

	//设置隐藏域等部分
	<?php if(isset($data['is_save_price']) && $data['is_save_price'] == 1){?>
	$('#protectBox').show();
	<?php }?>

	//设置统一费用
	<?php if(isset($data['price_type']) && $data['price_type'] == 1){?>
	$('#areaBox').show();
	<?php }?>

	//具有特殊省份设置
	<?php if(isset($data['area_groupid']) && $data['area_groupid']!=''){?>
	var area_groupid = <?php echo JSON::encode(unserialize($data['area_groupid']));?>;
	var firstprice   = <?php echo JSON::encode(unserialize($data['firstprice']));?>;
	var secondprice  = <?php echo JSON::encode(unserialize($data['secondprice']));?>;

    for(var index in area_groupid)
    {
    	var areaname = [];
    	var idArray  = area_groupid[index].split(';');
    	for(var i in idArray)
    	{
    		if(idArray[i])
    		{
    			areaname.push(getAreaName(idArray[i]));
    		}
    	}
		var areaHtml = template.render('areaTemplate',{"area_groupid":area_groupid[index],"areaname":areaname.join(','),"firstprice":firstprice[index],"secondprice":secondprice[index]});
		$('#deliveryAreaBox').append(areaHtml);
    }
	<?php }?>
});

//添加地域项
function addArea()
{
	var areaHtml = template.render('areaTemplate',{});
	$('#deliveryAreaBox').append(areaHtml);
}

//获取省份名称
function getAreaName(provinceId)
{
	var areaNameList = <?php echo JSON::encode($this->area);?>;
	return areaNameList[provinceId];
}

//添加省份
function addProvince(_self)
{
	var parentObject = $(_self).parent();
	var selectObj    = parentObject.find('select');

	//当前选中的地区ID
	var areaGroupId = parentObject.find('input[name="area_groupid[]"]').val();

	//当前选中的地区NAME
	var areaGroupName = parentObject.find('textarea[name="areaName"]').val();

	//填写areaId
	if(areaGroupId == '')
	{
		parentObject.find('input[name="area_groupid[]"]').val(";" + selectObj.val() + ";");
	}
	else if(areaGroupId.indexOf(";" + selectObj.val() + ";") == -1)
	{
		parentObject.find('input[name="area_groupid[]"]').val(areaGroupId + selectObj.val() + ";");
	}
	else
	{
		alert('省份已经添加，不要重复添加');
		return;
	}

	//添加areaName
	areaGroupName = areaGroupName == '' ? selectObj.find('option:selected').text() : areaGroupName + "," + selectObj.find('option:selected').text();
	parentObject.find('textarea[name="areaName"]').val(areaGroupName);
}
</script>
	</section>
	<!--主题内容 结束-->

	<script type="text/javascript">
	//菜单图片ICO配置
	function menuIco(val)
	{
		var icoConfig = {
			"个人中心":"icn_profile",
			"供应商商品购买" : "icn_photo",
			"管理首页" : "icn_tags",
			"销售额统计" : "icn_settings",
			"货款明细列表" : "icn_categories",
			"货款结算申请" : "icn_photo",
			"商品列表" : "icn_categories",
			"添加商品" : "icn_new_article",
			"平台共享商品" : "icn_photo",
			"商品咨询" : "icn_audio",
			"商品评价" : "icn_audio",
			"商品退款" : "icn_audio",
			"规格列表" : "icn_categories",
			"实物交易订单列表" : "icn_categories",
			"到店服务订单列表" : "icn_categories",
			"团购" : "icn_view_users",
			"促销活动列表" : "icn_categories",
			"物流配送" : "icn_folder",
			"发货地址" : "icn_jump_back",
			"资料修改" : "icn_profile",
		};
		return icoConfig[val] ? icoConfig[val] : "icn_categories";
	}

	$(".toggle>li").each(function()
	{
		$(this).addClass(menuIco($(this).text()));
	});
	
	//$this->seller['seller_id']
	</script>
	

	<?php if($user_id){?>
	
		<input class="self_id" type="hidden" value="<?php echo isset($user_id)?$user_id:"";?>"/>
		<input class="self_name" type="hidden" value="<?php echo isset($user_name)?$user_name:"";?>"/>
			
		
		
		<!-- 右边竖条  s-->
		<div class="right">
			<span>在线联系</span>
			<div class="message" id="showFriend" >
				<a href="javascript:"></a>
			</div>
		</div>
		<!-- 右边竖条  e-->
		
		
		<!-- 聊天窗口我好友列表   s -->
		<div class="chat_list" >
			<div class="chat_top">
				<h1>
					<i></i>
					联系人
				</h1>
				<span class="close"></span>		
			</div>
		<?php $f_uid?> <!-- 对方的id -->
		
		<!-- 好友列表 s -->
	<div class="chat_user">
		<dl class="chat_user_friend">
			<dt>
				我的好友
				<span class="show"></span>
			</dt>
			<!-- 查找好友表 -->
			<?php $query = new IQuery("friends");$query->where = "(f_id = $member_id or t_id = $member_id) and state = 1";$items = $query->find(); foreach($items as $key => $item){?>
				<?php if($item['f_id'] == $member_id){?>
					<?php $f_uid = $item['t_id']?>
				<?php }else{?>
					<?php $f_uid = $item['f_id']?>	
				<?php }?>	
			<dd from_id=<?php echo isset($f_uid)?$f_uid:"";?>>
				<span class="user_avatar">
					<?php $query = new IQuery("user");$query->where = "id = $f_uid";$items = $query->find(); foreach($items as $key => $first){?> 
						<?php if($first['head_ico'] == ""){?>
							<img alt="" src="<?php echo IUrl::creatUrl("upload/car.jpg");?>"> 
							<?php $ava_img='upload/car.jpg'?>
					 		<?php }else{?>
					 		<img alt="" src="<?php echo IUrl::creatUrl("".$first['head_ico']."");?>"> 
							<?php $ava_img=$first['head_ico']?>
					 	<?php }?>
					<?php }?>
					<i class="offline" f_id="<?php echo isset($f_uid)?$f_uid:"";?>"></i>
				</span>
				<?php if($item['f_id'] == $member_id){?>
					<h5><?php echo isset($item['t_name'])?$item['t_name']:"";?></h5>
					<a href="javascript:"  onclick="talk(<?php echo isset($member_id)?$member_id:"";?>,<?php echo isset($item['t_id'])?$item['t_id']:"";?>,<?php echo isset($item['id'])?$item['id']:"";?>,'<?php echo IUrl::creatUrl("".$ava_img."");?>','<?php echo isset($item['t_name'])?$item['t_name']:"";?>')"></a>
					<?php }else{?>
					<h5><?php echo isset($item['f_name'])?$item['f_name']:"";?></h5>
					<a href="javascript:"  onclick="talk(<?php echo isset($member_id)?$member_id:"";?>,<?php echo isset($item['f_id'])?$item['f_id']:"";?>,<?php echo isset($item['id'])?$item['id']:"";?>,'<?php echo IUrl::creatUrl("".$ava_img."");?>','<?php echo isset($item['f_name'])?$item['f_name']:"";?>')"></a>
				<?php }?> 
			</dd>
			<?php }?>
		</dl>
		
		<!-- 最近联系人 s -->
		<!-- 查找好友表 -->
		<dl class="chat_user_recent">
			<dt>
				最近联系人
				<span class="show"></span>
			</dt>
			
			<?php $query = new IQuery("friends");$query->where = "(f_id = $member_id or t_id = $member_id) and state = 0";$items = $query->find(); foreach($items as $key => $item){?>
				<?php if($item['f_id'] == $member_id){?>
					<?php $l_uid = $item['t_id']?>
				<?php }else{?>
					<?php $l_uid = $item['f_id']?>	
				<?php }?>		
				<dd from_id='<?php echo isset($l_uid)?$l_uid:"";?>'>
					<span class="user_avatar">
						<?php $query = new IQuery("user");$query->where = "id = $l_uid";$items = $query->find(); foreach($items as $key => $first){?> 
							<?php if($first['head_ico'] == ""){?>
								<img alt="" src="<?php echo IUrl::creatUrl("upload/car.jpg");?>"> 
								<?php $ava_img='upload/car.jpg'?>
						 		<?php }else{?>
						 		<img alt="" src="<?php echo IUrl::creatUrl("".$first['head_ico']."");?>"> 
								<?php $ava_img=$first['head_ico']?>
					 		<?php }?>
						<?php }?>
						<i class="offline" f_id="<?php echo isset($l_uid)?$l_uid:"";?>"></i>
					</span>
					<?php if($item['f_id'] == $member_id){?>
					<h5><?php echo isset($item['t_name'])?$item['t_name']:"";?></h5>
					<a href="javascript:"  onclick="talk(<?php echo isset($member_id)?$member_id:"";?>,<?php echo isset($item['t_id'])?$item['t_id']:"";?>,<?php echo isset($item['id'])?$item['id']:"";?>,'<?php echo IUrl::creatUrl("".$ava_img."");?>','<?php echo isset($item['t_name'])?$item['t_name']:"";?>')"></a>
					<?php }else{?>
					<h5><?php echo isset($item['f_name'])?$item['f_name']:"";?></h5>
					<a href="javascript:"  onclick="talk(<?php echo isset($member_id)?$member_id:"";?>,<?php echo isset($item['f_id'])?$item['f_id']:"";?>,<?php echo isset($item['id'])?$item['id']:"";?>,'<?php echo IUrl::creatUrl("".$ava_img."");?>'),'<?php echo isset($item['f_name'])?$item['f_name']:"";?>' "></a>
				<?php }?> 
				</dd>
			<?php }?>
		</dl>
		
	</div>
	<!-- 好友列表 e -->
	
</div>
	
		
			
	<?php }?>
	
	
<?php if($user_id){?>
<!-- 聊天窗口内容接收与发送 s msg-dialog 1-->
<?php $i=1?>	
<?php $to_Id?>
<?php $to_uname?>
<?php $ava?>
<?php $query = new IQuery("friends");$query->where = "f_id = $member_id or t_id = $member_id";$items = $query->find(); foreach($items as $key => $item){?>
		<?php if($item['f_id'] == $member_id){?>
			<?php $to_Id = $item['t_id']?>
			<?php }else{?>
			<?php $to_Id = $item['f_id']?>
		<?php }?>
		
		<?php $query = new IQuery("user");$query->where = "id = $to_Id";$items = $query->find(); foreach($items as $key => $first){?>
			<?php $to_uname = $first['username']?>
			<?php if($first['head_ico'] == ""){?>
				
				<?php $ava='upload/car.jpg'?>
			<?php }else{?>
				<?php $ava = $first['head_ico']?>
			<?php }?>
		<?php }?>
		
<div class="msg-dialog isshow<?php echo isset($item['id'])?$item['id']:"";?>" id="dialog" draggable="false" from_id="">
	<div id="dialog_header" class="d_h" value="<?php echo isset($i)?$i:"";?>" draggable="true">
	<?php if($ava == ""){?>
		<img class="to_user_img" alt="" src="<?php echo IUrl::creatUrl("upload/car.jpg");?>"> 
		<?php }else{?>
		<img class="to_user_img" alt="" src="<?php echo IUrl::creatUrl("".$ava."");?>"> 
	<?php }?>
		<span><?php echo isset($to_uname)?$to_uname:"";?></span>
		<div class="close_big">
			<span>×</span>
		</div>
	</div>
	
	
	<input class="to" type="hidden" value="<?php echo isset($to_Name)?$to_Name:"";?>"/>
	
	<!-- 聊天记录 -->
	<div class="dialog-body">
		<!-- 用户的聊天内容 -->
		<div class="msg_list">
			<div class="chat_con"> 
				<!-- 发送者信息 -->
			<!--	<div class="to_user">
					<span class="user-avatar">
						<img alt="" src="<?php echo IUrl::creatUrl("")."".$user_ico."";?>">
					</span>-->
					<!-- 发送给用户的内容 s-->
					<!--<dl>
						<dt>2017-05-16 10:49:19</dt>
						<dd>kdf;msdlfmmsdlfmsdklfmsdklmsdlfmmsdlfmsdklfmsdklgsdklfmsdklggsdklfmsdklg</dd>
						<dd class="arrow"></dd>
					</dl>
				</div>-->
				<!-- 发送给用户的内容 e-->
				
				<!-- 接收用户的内容  s-->
				<!-- <div class="from_user">
					<span class="user-avatar">
						<img alt="" src="<?php echo $this->getWebSkinPath()."image/logo.png";?>">
					</span> -->
					<!-- 发送内容 -->
					<!--<dl>
						<dt>2017-05-16 10:49:19</dt>
						<dd>kdf;msdlfmmsklmsdlfmmsklfklfmsdklgmsdlfmmsklfklfmsdklgfklfmsdklg</dd>
						<dd class="arrow"></dd>
					</dl>
				</div> -->
				<!-- 接收用户的内容 e-->
				
			</div>
		</div>
		<div class="msg-input-box">
			<!-- 表情栏 s-->
			
			<!-- 表情 -->
			<div class="s_img">
				<?php for($num = 1 ; $num<=77 ; $num = $num+1){?>
					<div  class="event_one">
						<img alt="<?php echo isset($num)?$num:"";?>.gif" src="<?php echo IUrl::creatUrl("upload/talkimg/".$num."");?>.gif">
					</div>
				<?php }?>
			</div>
			
			<div class="msg-input-title">
				<span class="chat_show">
					<img alt="" src="<?php echo $this->getWebSkinPath()."image/show.png";?>">
				</span>
				
				<span class="chat_phpne">
					<img alt="" src="<?php echo $this->getWebSkinPath()."image/photo.png";?>" class="photo_upload">
						<input type="file" id="upp" name="photo" style="display: none" onchange="select_photo()" />
					</img>
				</span>
				
				<span class="message">
					消息记录
					<img alt="" src="<?php echo $this->getWebSkinPath()."image/down.png";?>">
				</span>
			</div>
			<!-- 表情栏 e-->
			
			<!-- 内容输入框 s-->
			<textarea class="send_message"></textarea>
			<!-- 内容输入框 e-->
			<span class="ad"><a href="#">广告词可以在这里加链接</a></span>
			<span class="send_btn" ><a href="javascript:">发送消息</a></span>
						
		</div>
	</div>
	
	<div class="dialog_chat_right" >
		<!-- 消息记录 -->
	</div>
	
</div>
<?php $i=$i+1?>	
<?php }?>
<?php }?>
<!-- 聊天窗口内容接收与发送 s msg-dialog-->	

	
</body>
</html>

<script>
$(function(){
	//聊天
	$(".message").mouseover(function(){
		$(".right span").show();
	});
	
	$(".message").mouseout(function(){
		$(".right span").hide();
	});
	
	//响应拖拽
	var dh = $(".d_h");
	for(var i=0; i < dh.length; ++i){
		var dialog_header = dh[i];
		var flag = false;
		
		dialog_header.ondragstart  = function(){
			flag = true;
			var index = $(this).attr("value");
			
			test(flag,index-1);
			
		}
		dialog_header.ondragend = function(){
			console.log("down");
			flag = false;
			var index = $(this).attr("value");
			test(flag,index-1);
		}
	}
	
	
	$(".close").click(function(){
		$(".chat_list").css("-webkit-transform","translateX(500px)");
	});
	
	
	$("#showFriend").click(function(){
		$(".chat_list").css("-webkit-transform","translateX(0px)");
	});
		
});

//拖动窗口响应
function test(flag,index){
	if(!flag){
		//document.getElementById("dialog").draggable = false;
		$(".msg-dialog")[index].draggable = false;
		return ;
	}
	//document.getElementById("dialog").draggable = true;
	var md = $(".msg-dialog");
	md[index].draggable = true;
	/*
	for(var i=0;i<md.length;++i){
		md[i].draggable = true;
	}*/
	//console.log(this);
	//$(".msg-dialog").html().draggable = true;
	//var dragdiv = document.querySelector(".msg-dialog");
	
	var dragdiv = md[index];
   	var x, y;  //记录到点击时鼠标到移动框左边和上边的距离

    dragdiv.addEventListener('dragstart', function (e) {
        e.dataTransfer.effectAllowed = "move";  //移动效果
        e.dataTransfer.setData("text", '');  //附加数据，　没有这一项，firefox中无法移动
        x = e.offsetX || e.layerX;
        y = e.offsetY || e.layerY;
        return true;
    }, false);

    document.addEventListener('dragover', function (e) {//取消冒泡 ,不取消则不能触发 drop事件
        e.preventDefault()|| e.stopPropagation();
    }, false);

    document.addEventListener('drop', function (e) {
        dragdiv.style.left = (e.pageX - x) + 'px';
        dragdiv.style.top = (e.pageY - y) + 'px';
        e.preventDefault() || e.stopPropagation();  //不取消，firefox中会触发网页跳转到查找setData中的内容
    }, false);
}

</script>














